# coding=utf-8
import logger
#import main_ppp
import net_test
import ppp_test
import re
import os
import sys
import time
import test
import client
from key_event import sigint

execfile("../cfg/at/other.cfg")

all_test = False
basic_test = False
ppp_test_flag = False
netCard_test = False
cmux_test = False
test_mode = 0
if test_num == 0:
    all_test = True
elif test_num == 1:
    basic_test = True
elif test_num == 2:
    test_mode = 1
    ppp_test_flag = True
elif test_num == 3:
    test_mode = 2
    netCard_test = True
elif test_num == 4:
    test_mode = 3
    cmux_test = True

def run_main():	
	print 'Luat AT automatic test tool'
	print 'Version: 1.0.7'
	print '按下Ctrl+c停止运行'
	current_test = test.Test('result.ini',test_mode)
	test.test_object = current_test
	# current_test.test_start()
	sigint()
	for i in range(test_main_loop): 
		if ppp_test_flag or all_test or cmux_test:
			if cmux_test:
				print '******开始进行cmux PPP拨号测试******'
				test.test_mode = 3
			else:
				print '******开始进行PPP拨号测试******'
				test.test_mode = 1
			print 'AT端口是：'+ dev_port
			ppp_test.run(current_test)
		elif netCard_test or all_test:
			print '********开始进行网卡测试********'
			test.test_mode = 2
			print 'AT端口是：'+ dev_port
			net_test.run(current_test)
		elif basic_test or all_test:
			print '********开始进行AT指令测试**********'
			print 'AT端口是：'+ dev_port
			import main_basic
	current_test.test_exit()

run_main()


'''test.pid = os.fork()

if test.pid == 0:
    nowTime = time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime(time.time()))
    os.execl("./../bin/diag", "diag", "../log/"+log_dir+'/'+nowTime)
else:
    run_main()'''
